package com.czy.feign.cilent;

import com.czy.feign.pojo.User;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author czy
 * @create 2018-04-15 23:25
 **/
@Component
public class MovieClientFallbackFactory implements FallbackFactory<MovieClientFactory>
{
	@Override
	public MovieClientFactory create(Throwable throwable)
	{
		if (throwable == null)
		{
			throwable.printStackTrace();
		}
		return new MovieClientFactory()
		{
			@Override
			public List<User> findUserAll()
			{
				User u = new User();
				u.setId(-1);
				u.setName("error");
				List<User> list = new ArrayList<>();
				list.add(u);
				return list;
			}
		};
	}
}
